#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <cstdlib>
using namespace std;
#define forn(i,n) for(int i=0;i<int(n);++i)
#define dforn(i,n) for(int i=(n)-1;i>=0;--i)
#define forsn(i,s,n) for(int i=s;i<int(n);++i)
#define forall(it,X) for(typeof(X.begin()) it = X.begin(); it != X.end(); ++it)

int rnd(int n) { return rand()%n; }
#define DIV (1<<20)
double rndDbl(int n) { return double(rnd(n*DIV+1))/double(DIV); }

void genPunto(ostream& o, int n, int a, int b) {
	double i=rndDbl(n),j=rndDbl(n);
	double* p=(a?&i:&j);
	*p=(b?0:n);
	o.precision(20);
	o << i;
	o << " ";
	o.precision(20);
	o << j;
}

void genRayo(ostream& o, int n) {
	int x=rnd(4);
	int y=rnd(3); if (y>=x) y++; //avoid making rays over the border
	genPunto(o,n,x&1,x>>1);
	o << " ";
	genPunto(o,n,y&1,y>>1);
	o << endl;
}

int main() {
	
	ifstream in("input.txt");
	ofstream out("output.txt");
	int n,m,seed;
	double d,sigma;
	in >> n >> m >> seed >> sigma;
	//rnd(1<<15) is the seed for the next program
	out << n << " " << m << " " << rnd(1<<15) << " " << sigma << endl;
	forn(i,n) {
		forn(j,n) {in >> d; out.precision(20); out << (j?" ":"") << d; }
		out << endl;
	}
	srand(seed);
	forn(i,m) genRayo(out,n);
    return 0;
}
